﻿' Copyright © Microsoft Corporation.  All Rights Reserved.
' This code released under the terms of the 
' Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)
' <copyright file="ScriptableObservableCollection.vb" company="Microsoft">
'     Copyright © Microsoft Corporation. All rights reserved.
' </copyright>
' <summary>Implements a Scriptable version of the ObservableCollection class</summary>
' <author>Microsoft Expression Encoder Team</author>

Imports Microsoft.VisualBasic
Imports System.Collections.ObjectModel
Imports System.Windows.Browser

Namespace ExpressionMediaPlayer
	Public Class ScriptableObservableCollection(Of T)
		Inherits ObservableCollection(Of T)
		''' <summary>
		''' observable collection callable through scripting
		''' </summary>
		Public Sub New()
		End Sub
		''' <summary>
		''' add item
		''' </summary>
		''' <param name="item">itemt o add</param>
		<ScriptableMember> _
		Public Shadows Sub Add(ByVal item As T)
			MyBase.Add(item)
		End Sub
		''' <summary>
		''' index item
		''' </summary>
		''' <param name="index">index</param>
		''' <returns>item</returns>
		<ScriptableMember> _
		Default Public Shadows Property Item(ByVal index As Integer) As T
			Get
				Return MyBase.Item(index)
			End Get
			Set(ByVal value As T)
				MyBase.Item(index) = value
			End Set
		End Property
		''' <summary>
		''' number of items in collection
		''' </summary>
		<ScriptableMember> _
		Public Shadows ReadOnly Property Count() As Integer
			Get
				Return MyBase.Count
			End Get
		End Property
		''' <summary>
		''' clear collection
		''' </summary>
		<ScriptableMember> _
		Public Shadows Sub Clear()
			MyBase.Clear()
		End Sub
		''' <summary>
		''' does list contain this item
		''' </summary>
		''' <param name="item">item to find</param>
		''' <returns>item found</returns>
		<ScriptableMember> _
		Public Shadows Function Contains(ByVal item As T) As Boolean
			Return MyBase.Contains(item)
		End Function
		''' <summary>
		''' return index of this item
		''' </summary>
		''' <param name="item">item to find</param>
		''' <returns>index of this item</returns>
		<ScriptableMember> _
		Public Shadows Function IndexOf(ByVal item As T) As Integer
			Return MyBase.IndexOf(item)
		End Function
		''' <summary>
		''' insert item into collection
		''' </summary>
		''' <param name="index">index to insert at</param>
		''' <param name="item">item to insert</param>
		<ScriptableMember> _
		Public Shadows Sub Insert(ByVal index As Integer, ByVal item As T)
			MyBase.Insert(index, item)
		End Sub
		''' <summary>
		''' remove item at this index
		''' </summary>
		''' <param name="index">index to remove at</param>
		<ScriptableMember> _
		Public Shadows Sub RemoveAt(ByVal index As Integer)
			MyBase.RemoveAt(index)
		End Sub
		''' <summary>
		''' remove item from collection
		''' </summary>
		''' <param name="item">item to remove</param>
		''' <returns>true if found and removed</returns>
		<ScriptableMember> _
		Public Shadows Function Remove(ByVal item As T) As Boolean
			Return MyBase.Remove(item)
		End Function
	End Class
End Namespace
